package com.bling.action;

import java.sql.SQLException;

import javax.annotation.Resource;

import com.bling.action.base.BaseAction;
import com.bling.common.bean.Area;
import com.bling.common.constant.ActionReturn;
import com.bling.common.page.PageResult;
import com.bling.common.util.CommonTypeChange;
import com.bling.iservice.IAreaService;
/**
 * 地区分页展示
 * @author chen-zhenxing
 *
 */
public class AreaPageAction extends BaseAction {
	/**
	 * 分页展示地区
	 * @return
	 */
	public String page(){
		int ps = CommonTypeChange.getIntFromString(this.getS());
		if(ps<1)
			ps=PageResult.getDefaultPageSize();
		int pc = CommonTypeChange.getIntFromString(this.getC());
		if(pc<1)
			pc=1;
		try {
			this.setPageData(areaService.listAreaByPage((pc-1)*ps,ps));
			pageData.setPagesize(ps);
			pageData.setPagecurrent(pc);
		} catch (SQLException e) {
			return ActionReturn.ERROR;
		}
		return ActionReturn.JSP;
	}
	
	private static final long serialVersionUID = -7260517711155728472L;
	/**
	 * 地区服务
	 */
	@Resource
	private IAreaService areaService;
	/**
	 * 单页数据
	 */
	private PageResult<Area> pageData;
	/**
	 * 以下缩写为了在页面url中地址显示简单
	 * 防止被轻易看出地址
	 */
	private String s; // 每页显示条数缩写
	private String c; // 当前第几页缩写
	public IAreaService getAreaService() {
		return areaService;
	}
	public void setAreaService(IAreaService areaService) {
		this.areaService = areaService;
	}
	public PageResult<Area> getPageData() {
		return pageData;
	}
	public void setPageData(PageResult<Area> pageData) {
		this.pageData = pageData;
	}
	public String getS() {
		return s;
	}
	public void setS(String s) {
		this.s = s;
	}
	public String getC() {
		return c;
	}
	public void setC(String c) {
		this.c = c;
	}
}
